﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Streambolics.Web;

namespace Streambolics.Ha7Net
{
    public class Ha7NetSensorData : WebPageContents, IRealTimeDataProducer
    {
        public static string SensorUrl (string aBox, string aSensorId)
        {
            return "http://" + aBox + "/Blob=" + aSensorId;
        }

        public Ha7NetSensorData (string aBox, string aSensorId)
            : base (SensorUrl (aBox, aSensorId))
        {
        }

        #region IRealTimeDataProducer Members

        public bool GetRealTimeData (out double aValue, out DateTime aTimeStamp)
        {
            string s = TimedGetActualContent ();

            if (s != null)
            {
                aValue = 0;
                aTimeStamp = DateTime.Now;
                return true;
            }
            else
            {
                aValue = 0;
                aTimeStamp = DateTime.MinValue;
                return false;
            }
        }

        #endregion
    }
}
